<!--
	THIS EXAMPLE WAS DOWNLOADED FROM https://echarts.apache.org/examples/zh/editor.html?c=graph-force
-->
<!DOCTYPE html>
<html lang="zh-CN" style="height: 100%">
<head>
  <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
  <div id="container" style="height: 100%"></div>

  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/jquery"></script>
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@5.3.3/dist/echarts.min.js"></script>
  <!-- Uncomment this line if you want to dataTool extension
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@5.3.3/dist/extension/dataTool.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use gl extension
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts-gl@2/dist/echarts-gl.min.js"></script>
  -->
  <!-- Uncomment this line if you want to echarts-stat extension
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts-stat@latest/dist/ecStat.min.js"></script>
  -->
  <!-- Uncomment this line if you want to use map
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@4.9.0/map/js/china.js"></script>
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@4.9.0/map/js/world.js"></script>
  -->
  <!-- Uncomment these two lines if you want to use bmap extension
  <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=YOUR_API_KEY"></script>
  <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@5.3.3/dist/extension/bmap.min.js"></script>
  -->

  <script type="text/javascript">
    var dom = document.getElementById('container');
    var myChart = echarts.init(dom, null, {
      renderer: 'canvas',
      useDirtyRect: false
    });
    var app = {};
    var ROOT_PATH = 'https://fastly.jsdelivr.net/gh/apache/echarts-website@asf-site/examples';
    var option;

    myChart.showLoading();
$.get(ROOT_PATH + '/data/asset/data/les-miserables.json', function (graph) {
  myChart.hideLoading();
  graph.nodes.forEach(function (node) {
    node.symbolSize = 5;
  });
  console.log(graph.nodes)
  console.log(graph.links)
  console.log(graph.categories)

  graph.nodes = [{"name":"HHV5|mRNA|UL121","category":1,"type":"mRNA","row":65,"x":298,"y":374},{"name":"HHV5|mRNA|UL117","category":1,"type":"mRNA","row":61,"x":85,"y":139},{"name":"HHV5|mRNA|IE72","category":1,"type":"mRNA","row":71,"x":246,"y":40},{"name":"HHV5|mRNA|UL120","category":1,"type":"mRNA","row":64,"x":215,"y":43},{"name":"HHV5|mRNA|UL142","category":1,"type":"mRNA","row":69,"x":267,"y":390},{"name":"HHV5|miRNA|hcmv-miR-US5-1","category":0,"type":"miRNA","row":76,"x":206,"y":183},{"name":"HHV5|miRNA|hcmv-miR-UL36-5p","category":0,"type":"miRNA","row":58,"x":44,"y":427},{"name":"HHV5|mRNA|US7","category":1,"type":"mRNA","row":76,"x":128,"y":87},{"name":"HHV5|mRNA|UL114","category":1,"type":"mRNA","row":66,"x":408,"y":228},{"name":"HHV5|miRNA|hcmv-miR-UL112-3p","category":0,"type":"miRNA","row":59,"x":216,"y":49},{"name":"HHV5|mRNA|UL123","category":1,"type":"mRNA","row":62,"x":107,"y":311},{"name":"HHV5|mRNA|AC146906.1","category":1,"type":"mRNA","row":70,"x":287,"y":178},{"name":"HHV5|miRNA|hcmv-miR-US5-2-3p","category":0,"type":"miRNA","row":77,"x":155,"y":106},{"name":"HHV5|mRNA|UL138","category":1,"type":"mRNA","row":58,"x":40,"y":65},{"name":"HHV5|mRNA|UL112","category":1,"type":"mRNA","row":59,"x":423,"y":291}]
  graph.links = [{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-US5-2-3p","target":"HHV5|mRNA|US7","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|IE72","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL117","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL114","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|AC146906.1","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL121","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-US5-1","target":"HHV5|mRNA|US7","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL112","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL123","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL120","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL112-3p","target":"HHV5|mRNA|UL142","energy":null},{"score":null,"name":"edgeName","source":"HHV5|miRNA|hcmv-miR-UL36-5p","target":"HHV5|mRNA|UL138","energy":null}]
  option = {
    title: {
      text: 'Les Miserables',
      subtext: 'Default layout',
      top: 'bottom',
      left: 'right'
    },
    tooltip: {},
    legend: [
      {
        // selectedMode: 'single',
        data: graph.categories.map(function (a) {
          return a.name;
        })
      }
    ],
    series: [
      {
        name: 'Les Miserables',
        type: 'graph',
        layout: 'force',
        data: graph.nodes,
        links: graph.links,
        categories: graph.categories,
        roam: true,
        label: {
          position: 'right'
        },
        force: {
          repulsion: 100
        }
      }
    ]
  };


  myChart.setOption(option);
});

    if (option && typeof option === 'object') {
      myChart.setOption(option);
    }

    window.addEventListener('resize', myChart.resize);
  </script>
</body>
</html>
